As part of my tool changer initialisation, I display a couple text boxes to confirm positions/tools. However, I can't get partial positions to display properly.
Here's the relevant code snippet-
char MyMessage[80]; // String to be created and displayed
double CrslP = *CrslPos/4;
printf("CrslPos = %d\n", *CrslPos);
printf("CrslP = %.1f\n", CrslP);
sprintf(MyMessage,"Is carousel at position %.1f",CrslP); // build the message we want to show
MsgBoxNoWait(MyMessage,MB_YESNO|MB_ICONEXCLAMATION);
*CrslPos is an integer/uservar that contains the carousel position (the numbered position gets multiplied by 4, as it runs on a Geneva mechanism with 2 rotation between each tool holder, and multiplyin by 4 allows me to track position, and use remainder calculations to test for a valid position)
What I'd like is when the carousel is at the mid-point between two holders, I want the message box to show x.5, however the fractional is shown as 0.
I.e. if the carousel is between 1 and 2, which would means CrslPos is 6, I want to display 1.5, but 1.0 gets displayed.
I'm sure the solution is blindingly obvious, but how can I get the .5 to show correctly?
Thanks,
Moray